package com.qiangesoft.bootcodegen.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * knife4j配置
 *
 * @author qiangesoft
 * @date 2024-03-12
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean
    public Docket codegenDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(this.apiInfo())
                .groupName("代码生成")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.qiangesoft.bootcodegen.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * api信息
     *
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("代码生成器")
                .description("# 基于SpringBoot+MyBatis-Plus的代码生成器")
                .contact(new Contact("强哥", "https://www.oicfx.cn", "718653463@qq.com"))
                .version("1.0")
                .build();
    }
}